#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
/**
 * @brief
 * nums.length == 2 * n
 * 1 <= n <= 500
 * 1 <= nums[i] <= 500
 *
 */
class Solution
{
public:
    bool divideArray(vector<int> nums)
    {
        vector<int> vec(501, 0);
        for (int num : nums)
        {
            ++vec[num];
        }
        bool flag = true;
        for (int i = 0; i < vec.size(); ++i)
        {
            if (vec[i] % 2)
            {
                flag = false;
                break;
            }
        }
        return flag;
    }
    bool divideArray_2(vector<int> &nums)
    {
        vector<int> v(501, 0);
        for (int num : nums)
        {
            v[num]++;
        }
        for (int i = 1; i <= 500; i++)
        {
            if (v[i] & 1)
            {
                return false;
            }
        }
        return true;
    }

    bool divideArray_3(vector<int> &nums)
    {
        int n = nums.size();
        sort(nums.begin(), nums.end());
        for (int i = 0; i < n; i = i + 2)
        {
            if (nums[i] != nums[i + 1])
                return false;
        }
        return true;
    }
};
int main()
{
    Solution s;
    cout << s.divideArray({1, 2, 3, 4, 5, 6}) << endl;
    return 0;
}
